<!DOCTYPE html>
<title>Document#onfullscreenerror</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(function(t)
{
    var sync = true;
    var promise_executed = false;
    assert_equals(document.onfullscreenerror, null, "initial onfullscreenerror");
    document.onfullscreenerror = t.step_func_done(function(event) {
        assert_true(promise_executed);
        assert_false(sync);
    });
    var e = document.createElement('span');
    var promise = e.requestFullscreen();
    if (promise) {
        promise.catch(()=> {
            assert_false(sync);
            promise_executed = true;
        });
    } else {
        // If promises aren't supported just treat it as already done.
        promise_executed = true;
    }
    sync = false;
});
</script>
